<?php
/** Copyright 2014 TinPhp Systems, Inc.
 * @author zhangxilian 2013-8-20
 * @package TinPhp
 */
require_once(TIN_APP_PATH . 'configs/site.conf.php');
/** 请求Soap服务客户端类 */
class PHYClient extends SoapClient {

    static $clienturi = TIN_PHY_URI;
    static $result;
    static $client;

    /** 初始化创建客户端Soap类
     * @param string $ws 远程服务类名称
     * @param string $user_name 远程服务用户名
     * @param string $pass_word 远程服务器密码
     * @param string $server 远程服务预定的URI */
    public function __construct($ws, $user_name, $pass_word, $server=TIN_PHY_APIURL) {
        $location = $server . "service.php?ws=" . $ws . "&username=" . $user_name . "&password=" . $pass_word;
        parent::SoapClient(null, array("location" => $location, "uri" => TIN_PHY_URI));
    }
    /** 调用远程服务方法
     * @param string $function_name 远程服务方法名称
     * @param object $arguments 远程服务方法需要的参数 */
    public function call($function_name, $arguments) {
        $data_cache_time = 86400;
        $geokey = md5($function_name . $arguments);
        $result = TinMemcache::get($geokey);
        if (!$result) {
            parent::__call($function_name, $arguments);
            TinMemcache::set($geokey, $result, (int) $data_cache_time);
        }
        return $result;
    }

}

?>
